﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using SmartSpace.WpfShell.ServiceRef;

namespace SmartSpace.WpfShell.Modules.Dynamic.Util
{
    public class DetailDataConvertor : System.Windows.Data.IValueConverter
    {
        public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            FieldMetadata detail = (FieldMetadata)parameter;
            return value.ToString();
        }

        public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            FieldMetadata metadata = (FieldMetadata)parameter;
            if (metadata.Type == "date")
            {
                return ((DateTime)value).ToString("yyyy-MM-dd");
            }
            return value.ToString();
        }
    }
}
